const options = {
  code: 0,
  msg: 'success',
};

const getDetail = (req, res) => {
  res.json({
    ...options,
    data: {
      name: 'test',
      description: '这是数据集描述信息这是数据集描述信息',
      createdAt: Date.now(),
      ownerType: Math.random() > .5 ? 'org' : 'group',
      sourceType: 'upload',
      dataType: Math.random() > .5 ? 'cv' : 'nlp',
      dataTask: Math.random() > .5 ? 'classification' : 'translation',
      annotFormat: Math.random() > .5 ? 'imagenet' : 'wmt',
      versionNum: 5,
      lastedVersion: 'v5',
      updatedAt: Date.now(),
      versionIds: [
        { id: 5, version: 'v5' },
        { id: 4, version: 'v4' },
        { id: 3, version: 'v3' },
        { id: 2, version: 'v2' },
        { id: 1, version: 'v1' },
      ],
      // platformAnnot: Math.random() > .5,
      platformAnnot: true,
    }
  })
};

const getAnnotInfo = (req, res) => {
  res.json({
    ...options,
    data: {
      taskId: Math.random(),
      taskName: '任务名称啊啊啊',
      // annotator: 'linxun',
      status: 'labeling',
      startTime: Date.now(),
      endTime: Date.now(),
      totalNum: 111,
      annotNum: 66,
      labelProportion: [
        { label: 'cat', number: 12 },
        { label: 'dog', number: 10 },
        { label: 'pig', number: 6 },
      ],
    }
  });
};

const getVersionList = (req, res) => {
  const pageNum = ~~req.query.pageNum;
  const pageSize = ~~req.query.pageSize;
  const result = [];
  for (let i = 1; i < 23; i++) {
    result.push({
      id: i,
      name: `数据集名称${i}`,
      version: `V${i}`,
      operator: 'linxun',
      itemNum: 99,
      labels: ['cat', 'dog', 'pig'],
      sourceVersion: 'V2',
      sourceType: Math.random() > .5 ? 'edit' : 'publish',
      createdAt: Date.now(),
      isPublish: false,
    });
  }
  const start = (pageNum - 1) * pageSize;
  const end = pageNum * pageSize;
  return res.json({
    ...options,
    data: {
      items: result.slice(start, end),
      total: result.length,
    }
  });
};

const donwload = {
  ...options,
  data: {
    downloadLink: 'https://www.baidu.com'
  }
};

export default {
  'GET /adhub/api/v1/datasets-collection/:id': getDetail,
  'POST /adhub/api/v1/datasets-collection/:id': options,
  'GET /adhub/api/v1/datasets/:id/annots': getAnnotInfo,
  'GET /adhub/api/v1/datasets-collection/:id/versions': getVersionList,
  'POST /adhub/api/v1/datasets/:id/download': donwload,
  'POST /adhub/api/v1/datasets/:id/publish': options,
  'DELETE /adhub/api/v1/datasets/:id': options,
}